define(['jquery', 'artTemplate', 'cookie'], ($, template) => {
  $('<header>').load('/includes/header.html', () => {
    $('.index-search input').on('focus', e => {
      console.log('获得焦点')
      $.getJSON('http://www.xiongmaoyouxuan.com/api/search/home', resData => {
        // resData.data.Hotwords.map(item => ``)
        const html = template('suggest-template', { suggests: resData.data.hotWords })
        console.log(html)
        $('.suggest').html(html)
      })
      $('.index-search input').on('blur', e => {
        $('.suggest').html('')
      })

      // $.getJSON('http://www.xiongmaoyouxuan.com/api/search/home', data => console.log('成功', data))
      // $.getJSON('/mock/suggest.json', data => console.log('成功', data))
    })
    $.cookie.json = true
    const total = ($.cookie('cart') || []).reduce((result, curr) => result + curr.amount, 0)


    const _nickname = localStorage.getItem('nickname')
    console.log(_nickname)
    $('.nickname').html(_nickname)


    $('.index-shopping .btn-shopping .gwc-shu .g-shu').html(total)
  }).prependTo("body")
})